﻿@using Huirui.Cavan.Domain.MainBoundedContext.StockModule
@model Huirui.Cavan.Presentation.ViewModel.StockModule.IStockViewModel
@{
    Layout = null;
}
@using (Html.BeginForm(ActionConst.SEARCH, ControllerConst.STOCK, FormMethod.Post))
{
    <div class="tool_bar">
        <input id="stock_query" type="submit" style="display: none;" />
        <input id="stock_reset" type="reset" style="display: none" />
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-undo'" onclick="javascript:$('#stock_reset').click()">重置</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" onclick="javascript:$('#stock_query').click()">查询</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-print'">打印</a>
        <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-collapse'" onclick="toggleHeard()">折叠/展开</a>
    </div>
    <table class="form_heard">
        <tr>
            <td class="c100">
                <label>存货编号:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.ID, new { id = "stocklist_id" })
            </td>
            <td class="c100">
                <label>存货名称:</label>
            </td>
            <td class="c160">
                @Html.TextBoxFor(m => m.SearchParam.Name, new { id = "stocklist_name" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>存货性质:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.SearchParam.Nature, typeof(StockIdentifier.StockNature), new { id = "stocklist_nature", defaultText = "请选择", defaultValue = "0" })
            </td>
            <td class="c100">
                <label>存货类别:</label>
            </td>
            <td class="c160">
                @Html.DropDownListFor(m => m.SearchParam.StockTypeID, Model.StockTypes, new { id = "stocklist_stocktype" })
            </td>
        </tr>
        <tr>
            <td class="c100">
                <label>条形码:</label>
            </td>
            <td colspan="3">
                @Html.TextBoxFor(m => m.SearchParam.BarCode, new { id = "stocklist_barcode" })
            </td>
        </tr>
    </table>
    <table id="stocklist_gd" class="easyui-datagrid" toolbar="#stocklist_tb" title="存货列表">
        <thead>
            <tr>
                <th data-options="field:'ck',checkbox:'true',width:10"></th>
                <th data-options="field:'Id',width:80">存货编码</th>
                <th data-options="field:'Name',width:80">存货名称</th>
                <th data-options="field:'Specification',width:80">规格型号</th>
                <th data-options="field:'UnitTransfer',width:80">计量单位</th>
                <th data-options="field:'Nature',width:80">存货性质</th>
                <th data-options="field:'Type',width:80">类别</th>
                <th data-options="field:'BarCode',width:80">条形码</th>
            </tr>
        </thead>
    </table>
    <div id="stocklist_tb">
        <a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true" id="deleteStock">选择删除</a>
        <a href="#" class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="javascript:alert('打印列表')">打印列表</a>
        <a href="#" class="easyui-linkbutton" iconcls="icon-excel" plain="true" onclick="javascript:alert('引出')">引出</a>
    </div>
}
<script type="text/javascript">
    $(function () {
        $("form[action^='/stock']").submit(function () {
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {
                    if (result.total > 0) {
                        $('#stocklist_gd').datagrid({
                            idfield: 'ID',
                            singleSelect: 'true',
                            selectOnCheck: 'true',
                            fitColumns: 'true',
                            pagination: 'true',
                            data: result
                        });
                    }
                    else {
                        $('#stocklist_gd').datagrid('loadData', { total: 0, rows: [] });
                    }
                },
                error: function () {
                    alert('系统繁忙，请稍候再试');
                }
            })

            return false;
        });
    });
</script>
